interface GlobalEvent {
  name: string
  payload?: any
  timestamp: number
}

interface GlobalState {
  lastEvent: GlobalEvent | null
  isLoggedIn: boolean
}

export const useGlobalStore = defineStore('global-store', {
  state: (): GlobalState => ({
    lastEvent: null,
    isLoggedIn: false
  }),
  actions: {
    handleCefEvent(name: string, payload?: any) {
      this.lastEvent = { name, payload, timestamp: Date.now() }
      if (name === 'login') {
        this.isLoggedIn = true
      } else if (name === 'logout') {
        this.isLoggedIn = false
      }
    }
  }
})